﻿@using System.Globalization
@using PagedList;
@using PagedList.Mvc;
@model CleverCMS.Blog.Services.ViewModels.IndexModel

@{
    Layout = "~/themes/default/views/default.cshtml";
}

@section HeadContent{

}

@section TitleContent{
    Blog
}

<div class="row-fluid">
    <div class="span8 ">
        <div class="blog">
            
            @if (Model.Entries.Any(x => x.Visible))
            {
                foreach (var entry in Model.Entries)
                {
                    if (entry.Visible == true)
                    {
                        <div class="row-fluid">  
                            <div class="span2 orange">
                                <a href="javascript:;" class="blog-features date active">
                                    <p class="day">@entry.Created.Day</p>
                                    <p class="month">@entry.Created.Date.ToString("MMM")</p>
                                </a>
                                <a href="@Url.Action("Entry", "Blog", new {Id = entry.Alias, Category = entry.Category.Alias.ToLower()})#com" class="blog-features comments">
                                    <i class=" icon-comments-alt"></i>
                                    <p class="info">@entry.BlogEntryComments.Count Comments</p>
                                </a>
                                <a href="javascript:;" class="blog-features comments">
                                    <i class=" icon-eye-open"></i>
                                    <p class="info">@entry.ViewCount Views</p> 
                                </a> 
                            </div>
                            <div class="span10">
                                <h2>
                                    <a href="@Url.Action("Entry", "Blog", new {Id = entry.Alias, Category = entry.Category.Alias.ToLower()})">@entry.Header</a>
                                </h2>
                                <p> 
                                BY <a href="javascript:;" class="author">@entry.Author</a> | @Html.Raw(entry.Created.ToString("MMM", CultureInfo.InvariantCulture) + " " + entry.Created.DayOfWeek.ToString() + ", " + entry.Created.ToShortTimeString())
                               @* <img alt="" src="">*@
                                <p>@Html.Raw(entry.ShortContent)...<a href="@Url.Action("Entry", "Blog", new {Id = entry.Alias, Category = entry.Category.Alias.ToLower()})" class="read-more">Continue Reading</a> </p>
                            </div> 
                        </div> 
                
                          
                    }
                }
                
                <div class="custom-pagination pagination-centered">
                    @(ViewBag.IsArchive == true ? Html.PagedListPager((IPagedList) Model.Entries, page => Url.Action("Archive", "Blog", new {Page = page})) : Html.PagedListPager((IPagedList) Model.Entries, page => Url.Action("Index", "Blog", new {Page = page})))
                </div>
                
            }
            else
            {
                <div class="custom-pagination pagination-centered">
                    <h2>No entries in this category</h2>
                </div>
                <br />
            }
           
        </div>
    </div>
    <div class="span4">
        @{Html.RenderPartial("_CategoriesControl", Model.Categories);}
        @{Html.RenderPartial("_LatestControl", Model.LatesBlog);}
        @{Html.RenderPartial("_TagsControl", Model.Tags);}
        @{Html.RenderPartial("_ArchiveControl", Model.Dates);}
    </div>
</div>